<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:ic="http://ivyteam.ch/jsf/component"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:pm="http://primefaces.org/mobile">
 
    <h:head>
        <title>Login :: E-Mail Application</title>
        <h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
        <script type="text/javascript">
        	jQuery(window).load(function($) {
        		checkIfUserAlreadyLoggedIn();
        	});
        </script>
    </h:head>
    <h:body>
        <h1>Welcome</h1>
        <h3>Please Login</h3>
        <h:form id="frmLogin">
        	<table>
        		<tr>
        			<td colspan="2">
        				<p:messages id="loginMessages" showDetail="true" closable="true" autoUpdate="true"></p:messages>
        			</td>
        		</tr>
        		<tr>
        			<td>Username: </td>
        			<td><p:inputText id="txtUsername" value="#{data.username}" /></td>
        		</tr>
        		<tr>
        			<td>Password: </td>
        			<td><p:password id="txtPassword" value="#{data.password}" /></td>
        		</tr>
        		<tr>
        			<td></td>
        			<td><p:commandButton id="btnLogin" value="Login" actionListener="#{logic.onBtnLoginClick}" /></td>
        		</tr>
        	</table>
        	<p:remoteCommand actionListener="#{logic.onLoginPageLoad}" name="checkIfUserAlreadyLoggedIn"></p:remoteCommand>
        </h:form>    	
    </h:body>
</html>